package com.android.task5;

import java.util.ArrayList;

import android.util.Log;



public class FlickrRESTApi {
	
	private final static String key = "af132e1981a446a441e273025b302f64";
	//Flickr REST API
	private final static String baseUrl = "http://api.flickr.com/services/rest";
	
	private final static String searchTag = "flickr.photos.search";
	private final static String getInfoTag = "flickr.photos.getInfo";
		
	protected static enum Method {search, getInfo};
	private static Method currentMethod = Method.search;
	
	private final static String INFO_TAG = "Flickr Request Info";
	
	ArrayList<String> tags;
	
	public FlickrRESTApi(){
		tags = new ArrayList<String>();
	}
	
	public void setSearchMethod(){
		currentMethod = Method.search;
	}
	
	public void setGetInfoMethod(){
		currentMethod = Method.getInfo;
	}
	
	public String getCurrentMethodTag(){
		if(currentMethod == Method.search) return searchTag;
		else return getInfoTag;
	}
	
	public String createStringURLForSearchTags(ArrayList<String> searchTags){
		setSearchMethod();
		String url = baseUrl;
		url += "?";
		url += "method=";
		url += getCurrentMethodTag();
		url += "&";
		url += "format=rest";
		url += "&";
		url += "api_key=";
		url += key;
		url += "&";
		url += "tags=";
		for(int i=0; i<searchTags.size(); i++){
		url += searchTags.get(i);
		if(i!=searchTags.size()-1)url += "+";
		}
		Log.i(INFO_TAG, url);
		return url;
	}
}
